package service

import (
	"fmt"
	"gin_jwt/internal/domain/model"
)

type SysUserService struct {
}

func NewSysUserService() *SysUserService {
	return &SysUserService{}
}

// 登录
func (this *SysUserService) Login(username string, password string) (*model.SysUser, error) {
	if username == "" || password == "" {
		return nil, fmt.Errorf("参数不能为空，username,password！")
	}

	for _, v := range model.SysUserList {
		if v.Username == username && v.Password == password {
			return &v, nil
		}
	}

	return nil, fmt.Errorf("登录失败，用户名或密码错误!")
}
